import moment from 'moment';

export default class extends think.BaseSocket {
    indexAction() {
        return this.successJson('hi video');
    }

    /**
     * 获取所有视频资源目录
     */
    async getCatalogAction() {
        // let ret = await think.Redis.hget('video', 'catalog');
        // //先找缓存
        // if (!think.isEmpty(ret)) {
        //     return this.successJson(JSON.parse(ret));
        // } else {
        const obj = {};
        const catalogList = await this.initUserToService('video/VideoService').getCatalogList();
        obj.count = catalogList.length;
        obj.list = catalogList;
        return this.successJson(obj);
        // }
    }

    /**
     * 云台控制
     * @returns {{success: boolean, msg: string, result: all, errorno: number}}
     */
    ptzControlAction() {
        const {deviceId, cmdType, speed} = this.post();
        think.CatalogVideo.ptzControl(deviceId, cmdType, speed);
        return this.successJson();
    }
    async saveAction() {
        return this.action('cms/EventController', 'allEventReport');
    }
}
